package advanced.thread;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.net.URL;
import java.util.concurrent.*;

public class L4 implements Callable<Boolean> {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //创建执行任务
        ExecutorService ser = Executors.newFixedThreadPool(3);
        //提交执行
        Future<Boolean> result1 = ser.submit(new L4());
        //获取结果
        boolean r1 = result1.get();
        //关闭服务
        ser.shutdownNow();


    }

    @Override
    public Boolean call() throws Exception {
        String dest = "C:\\Users\\DMLYS\\Documents\\prepare_for_work\\pfw\\java_l\\src\\main\\java\\advanced\\thread\\baidu.jpg";
        FileUtils.copyURLToFile(new URL("https://www.baidu.com/img/superlogo_c4d7df0a003d3db9b65e9ef0fe6da1ec.png?where=super"), new File(dest));

        return true;
    }
}
